package com.sunyzc.ebaotech.simulator.ybt.gzrcb;

import com.sunyzc.ebaotech.simulator.ybt.AbstractYBTProcessor;

/**
 * 1021 - 新单试算(101) <br>
 * 1022 - 新单缴费(102) <br>
 * 1013 - 保单重打(103) <br>
 * 1002 - 当日悔单(201) <br>
 * 801 - 日结对账(801)(注意实际是没有对账请求的交易的) <br>
 * TODO 1012 - 保全查询(117)(参考农行犹退、退保) <br>
 * TODO 1016 - 保单查询(106) <br>
 */
public class GZRCBProcessor extends AbstractYBTProcessor {
	private final static int HEAD_LENGTH = 16;
	private final static int BODY_LENGTH_BEGIN_INDEX = 8;
	private final static int BODY_LENGTH_END_INDEX = 16;

	@Override
	public byte[] generateHeadBytes(String requestTransType, byte[] bodyContent) throws Exception {
		String requestHeadContent = "INSU" + requestTransType + String.format("%08d", bodyContent == null ? 0 : bodyContent.length); // INSU(4字节) + 交易码(4字节) + 包长(8 字节，左补0)
		return requestHeadContent.getBytes(getClientConfig().getTransEncoding());
	}

	@Override
	protected int getHeadLength() {
		return HEAD_LENGTH;
	}

	@Override
	protected int getBodyLengthBeginIndex() {
		return BODY_LENGTH_BEGIN_INDEX;
	}

	@Override
	protected int getBodyLengthEndIndex() {
		return BODY_LENGTH_END_INDEX;
	}
}
